home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 9
/
The PC-SIG Library on CD ROM - Ninth Edition.iso
/
401_500
/
DISK0443
/
DISK0443.ZIP
/
TSCORE.S3I
< prev
next >
Wrap
Text File
|
1987-01-09
|
9KB
|
258 lines
program TSCORE
c$
c$ Compute weighted average of assignment and test scores, and the
c$ T score where T = 10*((x-mu)/sigma) + 50, mu = mean, sigma =
c$ standard deviation.
c$
c$ ***** Input **********************************************
c$
c$ First is a line that is used as a page heading for all output.
c$ This should not be enclosed in quotes.
c$
c$ Second is number of scores (integer) followed by pairs consisting
c$ of possible score (integer) and weight (integer), all separated by
c$ commas.
c$
c$ Remaining inputs each consist of student name in quotes
c$ (character) followed by student ID number (integer) and all scores
c$ (integer), with all quantities for each student separated by
c$ commas.
c$
c$ Fortran list input is used. Therefore, input for each student may
c$ consist of as many lines as necessary.
c$
c$ Input is terminated by end-of-file.
c$
c$ ***** Output *********************************************
c$
c$ Output consists of the input, with student scores augmented by the
c$ weighted average of all scores, scaled onto 0% to 100% range
c$ (identified by Raw% column heading), and the T score (identified
c$ by T column heading). This output is first printed in the order
c$ submitted, and second printed in decreasing order of T scores.
c$
c$ ***** Parameters *****************************************
c$
c$MXSCOR is the maximum number of scores per student. If this
c$ parameter is made greater than 14 the Format statements in
c$ procedure (print scores) must be changed.
c$MXSTUD is the maximum number of students.
c$
parameter (MXSCOR=14)
parameter (MXSTUD=60)
c$
c$ ***** Variables ********************************************
c$
c$DONE is a signal that end-of-file is present in input.
c$I is a loop induction variable.
c$ID is the set of student identification numbers.
c$INUNIT is the unit number from which to read input.
c$INWT is the set of relative weights of assignments and
c$ examinations.
c$J is a loop induction variable.
c$K is a loop induction variable.
c$LINE is a line of input, containing an input or output file name.
c$MU is the mean of composite scores in the RAW vector.
c$MUS is an array of means of columns of SCORES.
c$NBLANK is the number of blanks required to center a column heading in
c$ procedure (print scores).
c$NSCORE is the number of scores per student (assignments and
c$ examinations.
c$NSTDNT is the number of students.
c$OTUNIT is the unit number on which to write output.
c$P is a permutation vector used to sort results into descending
c$ order by T score.
c$PAGHDG is printed as a page heading for output.
c$RAW is the set of weighted scores, one per student. The RAW score
c$ for a student is the weighted average of all assignment and
c$ examination scores.
c$SCORES is the set of all scores.
c$SIGMA is the unbiased standard deviation of the RAW scores.
c$SIGMAS is an array of standard deviations of columns of SCORES.
c$SNAME is the set of student names.
c$SUMWT is the sum of weights of assignments and examinations. See
c$ WEIGHT below for explanation of use of SUMWT.
c$T is the set of T scores.
c$TOP is the set of maximum possible scores for assignments and
c$ examinations.
c$TT is a value of T, used while sorting results by descending
c$ order of T scores.
c$WEIGHT is the set of weights of assignments. WEIGHT is used in
c$ calculating the RAW score for each student. WEIGHT(I) is
c$ INWT(I) / (SUMWT * TOP(I)), where all arithmetic is performed
c$ in floating point. The inner product of TOP and WEIGHT is 1,
c$ and therefore all elements of RAW are between 0 and 1.
c$
character*80 PAGHDG
character*30 SNAME(MXSTUD)
integer I,ID(MXSTUD),INWT(MXSCOR),INUNIT,J,K
character*80 LINE
integer NBLANK,NSCORE,NSTDNT,OTUNIT
integer P(MXSTUD),SCORES(MXSTUD,MXSCOR),SUMWT,TOP(MXSCOR)
logical DONE
real MU,MUS(MXSCOR),RAW(MXSTUD),SIGMA,SIGMAS(MXSCOR),T(MXSTUD)
real TT,WEIGHT(MXSCOR)
c$
parameter (INUNIT=10, OTUNIT=11)
c$
c$ ***** Procedures *****************************************
c$
c$ Open input file.
c$
do forever
print *,'Enter input file name, or CON: for input from the'
print *,'keyboard: '
read (*,'(a80)') line
open (inunit,file=line,err=200)
exit forever
200 print *,'Unable to open input file. Try again? '
read (*,'(a80)') line
if (line(1:1).eq.'n'.or.line(1:1).eq.'N') stop
end forever
c$
c$ Open output file.
c$
do forever
print *,'Enter output file name, PRN: for output to the'
print *,'printer, or CON: for output to the console: '
read (*,'(a80)') line
open (otunit,file=line,err=210,carriage control='FORTRAN')
exit forever
210 print *,'Unable to open output file. Try again? '
read (*,'(a80)') line
if (line(1:1).eq.'n'.or.line(1:1).eq.'N') stop
end forever
c$
c$ Read the page heading.
c$
read (inunit,'(a80)') paghdg
c$
c$ Read number of scores, followed by possible score and weight for
c$ each assignment.
c$
read (inunit,*) nscore, (top(i),inwt(i), i=1, nscore)
c$
c$ Calculate sum of input weights.
c$
sumwt=0
do for i = 1, nscore
sumwt=sumwt+inwt(i)
end for
c$
c$ Calculate weight = inwt /(top * sum of inwt). Dividing by top
c$ here saves dividing by top when calculating raw scores.
c$
do for i = 1, nscore
weight(i) = float(inwt(i))/float(top(i)*sumwt)
end for
c$
c$ Make the averages for each assignment (MUS) zero. The total of
c$ scores for each assignment will be accumulated in MUS, and then
c$ divided by the number of students to calculate the averages.
c$
do for i = 1, nscore
mus(i) = 0.0
end for
c$
c$ Read scores for each student. Compute the raw score and
c$ accumulate the sum of raw scores to compute the mean.
c$
mu=0.0
nstdnt=0
do forever
nstdnt=nstdnt+1
read (inunit,*,done=end) sname(nstdnt), id(nstdnt)
1, (scores(nstdnt,i), i=1, nscore)
if (done) exit forever
raw(nstdnt)=0.0
do for i = 1, nscore
raw(nstdnt) = raw(nstdnt) + float(scores(nstdnt,i))*weight(i)
mus(i) = mus(i) + float(scores(nstdnt,i))
end for
mu = mu + raw(nstdnt)
end forever
nstdnt = nstdnt - 1
if (nstdnt.eq.0) then
print *,' No student scores submitted'
stop
end if
if (nstdnt.eq.1) then
print *,' Scores for only one student submitted'
stop
end if
mu = mu/float(nstdnt)
c$
c$ Compute MUS and SIGMAS.
c$
do for i = 1, nscore
mus(i) = mus(i)/float(nstdnt)
sigmas(i) = 0.0
do for j = 1, nstdnt
sigmas(i) = sigmas(i) + (float(scores(j,i))-mus(i))**2
end for
sigmas(i) = sqrt(sigmas(i)/(nstdnt-1))
end for
c$
c$ Compute sigma.
c$
sigma=0.0
do for i = 1, nstdnt
sigma = sigma + (raw(i)-mu)**2
end for
sigma = sqrt(sigma/(nstdnt-1))
c$
c$ Compute T scores.
c$
do for i = 1, nstdnt
t(i) = 10.0*(raw(i)-mu)/sigma+50.0
p(i) = i
end for
c$
c$ Print results, sort into descending order of T scores, print
c$ results again.
c$
nblank = (5*nscore-27)/2
do (print scores)
do for k = 2, nstdnt
tt = t(p(k))
do for j = 1, k-1
if (tt.gt.t(p(j))) then
i = p(k)
p(k) = p(j)
p(j) = i
tt = t(i)
end if
end for
end for
do (print scores)
c$
write (otunit,'(''1'')')
stop
c$
c$
procedure (print scores)
write (otunit,10) paghdg
10 format ('1',a80)
write (otunit,20) (' ',i=1,nblank),' Homework and Examinations '
20 format (t50,70a)
write (otunit,30) (top(i), i = 1, nscore)
30 format (t31,'Possible score',t50,14i5)
write (otunit,40) (inwt(i), i = 1, nscore)
40 format (t31,'Weight',t50,14i5)
write (otunit,50) ('-----', i = 1, nscore)
50 format ('0Student name',t31,' ID Raw% T',t50,14a5)
write (otunit,'()')
do for k = 1, nstdnt
i = p(k)
write (otunit,60) sname(i),id(i),raw(i),t(i)
1, (scores(i,j),j=1,nscore)
60 format (1x,a30,i5,2pf5.1,0pf5.1,t50,14i5)
end for
write (otunit,70) mu,(mus(i),i=1,nscore)
70 format ('0Mean',t37,2pf5.1,t51,0p14f5.0)
write (otunit,80) sigma,(sigmas(i),i=1,nscore)
80 format (' Standard Deviation',t37,2pf5.1,t51,0p14f5.1)
end procedure
c$
end program